﻿<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!-- <div class="header">
	<h2>
		填写<span><font color="red">（* 为必填项）</font> </span>
	</h2>
</div> -->
<form:form commandName="model" cssClass="validate"
	id="sparepartDetailForm" action="sparepart/sparepartChangeDetail/save">
	<form:hidden path="id" />
	<form:hidden path="typeKey" value="${model.typeKey }" />
	<form:hidden path="sptSparepartId" value="${model.sptSparepartId }" />

	<table class=" form-table">
		<tbody>
			<tr style="display:none">
				<td class="td1" style="width:18%">资产分类：</td>
				<td class="td2"><form:hidden path="confCategoryId" /> <isperp:treeSelector 
						id="confCategoryName" name="confCategoryName" displayValueCssStyle="width:300px;"
						displayValueCssClass="required"
						url="configuration/category/getTree?ty=companyCi"
						valueControlId="confCategoryId"
						displayValue="${model.confCategoryName}"></isperp:treeSelector></td>
			</tr>
			<tr>
				<td class="td1" style="width:18%">名称：</td>
				<td class="td2">
						<isperp:listSelector autocomplete="true" afterSelected="getSimilarCategoryByName()"
					id="nameSelector" afterSelectEmpty="getSimilarCategoryByName()" displayColumn="name"
					name="name" autocompleteDisplay="item.data[o.displayColumn]"
					autocompleteUrl="configuration/category/autocompleteInfolist?type=name"
					valueColumn="name" valueControlId=""
					displayValue=""
					displayValueCssStyle="width:249px" displayValueCssClass="required">
				</isperp:listSelector>
						
						</td>
			</tr>
			<%-- <tr>
				<td class="td1" style="width:18%">规格：</td>
				<td class="td2"><input id="ciId" name="ciId" class="hidden"
					type="text" maxlength="200" value="${model.id}" style="width:250px">
					<isperp:listSelector autocomplete="true" id="speSelector"
						afterSelected="afs(ids,names,rows);" afterSelectEmpty=""
						displayColumn="specification" name="specification"
						autocompleteDisplay="item.data[o.displayColumn]+'(<span style=\"color:red\">'+item.data[\"countnum\"]+'</span>)'" urlExtScript="'&categoryId='+$('#confCategoryId').val()"
						autocompleteUrl="sparepart/sparepart/autocompleteSpeclist?a=1"
						valueColumn="id" valueControlId="ciId" displayValue="${ciCode }"
						displayValueCssStyle="width:249px" displayValueCssClass=""
						url="sparepart/sparepart/autocompleteSpeclist?a=1">
						<isperp:column name="id" title="id" hidden="true"></isperp:column>
						<isperp:column name="specification" title="规格" width="80">
						</isperp:column>
						<isperp:column name="model" title="型号" width="150">
						</isperp:column>
						<isperp:column name="countnum" title="数量" width="150">
						</isperp:column>
						<isperp:column name="conf_category_name" title="类别" width="80">
						</isperp:column>
					</isperp:listSelector>
				</td>
			</tr> --%>
			<tr>
				<td class="td1" style="width:18%">设备号/PN号：</td>
				<td class="td2"><form:input path="model" cssClass=""
						cssStyle="width:249px;" /></td>
			</tr>
			<c:if test="${model.typeKey eq 'sparepartIn'}">
				<tr>
					<td class="td1" style="width:18%">单价：</td>
					<td class="td2"><form:input path="price" cssClass="number" />
					</td>
				</tr>
			</c:if>
			<tr>
				<td class="td1" style="width:18%">数量：</td>
				<td class="td2"><form:input path="quantity"
						cssClass="required number" value="1" /></td>
			</tr>
			<tr>
				<td class="td1" style="width:18%">备注：</td>
				<td class="td2"><form:textarea path="memo" /></td>
			</tr>
		</tbody>
	</table>
</form:form>
<script type="text/javascript">
	function getSimilarCategoryByName() {
	    var name=$("#nameSelector").val();
		$.ajax({
			url : "configuration/ci/getSimilarCategoryByName",
			data : {
				name : name
			},
			success : function(data) {
			    if(data)
			    {
			       $("#confCategoryId").val(data.id);
			       $("#confCategoryName").val(data.treenode_name_path);
			    }else
			    {
			       $("#confCategoryId").val("");
			       $("#confCategoryName").val("");
			    }
			}
		});
	}
	function clear() {
		$("#quantity").val("");
		$("#memo").text("");
		$("#price").val("");
		$("#specification").text("");
		$("#confCategoryId").val("");
		$("#confCategoryName").val("");
	}
	function afs(ids, names, rows) {
		var model = rows[0].model;
		$("#model").val(model);
	}
</script>
<isperp:buttonList>
	<button class="submit nui-mainbtn"
		onclick="isperp.submitForm({isCloseDialog:false,success:function(){window.top.isperp.reloadParentControl(isperp.getUrlParamByName('pcontrolid'));location.reload()}});return false;">保存并新增</button>
	<button class="submit nui-mainbtn"
		onclick="isperp.submitForm();return false;">保存</button>
</isperp:buttonList>



